
ResTaskEdit = new Pearlsen.BaseEdit({
	formId:'resApplyForm',
	idProperty:'taskId',
	moduleName:'ResTask',
	queryMethod:'getEntity',
	dataSetHandler:'ResTaskDataSetHandler',
	queryHandler:'ResTaskQueryHandler',
	saveMethod:'save',
	initFun:function(){
		this.applyId = this.getQueryString("applyId");
	},
	renderGrid:function(value,metaData,record,rowIndex,colIndex,store,view){
		var ret = '' ,memoryunit,storageunit;	
		var units =['MB','GB','TB'];
		var ops={XP_TPL:'Window XP',WIN7_TPL:'Window 7',LINUX_TPL:'LINUX'};
		opsSeries = record.data['opsSeries'];
		memoryunit = record.data['memoryunit'];
		storageunit = record.data['storageunit'];
		switch(colIndex){
			case 5:
				ret =ops[value];
				break;
			case 7:
				ret = value+units[memoryunit];
				break;
			case 8:
				ret = value +units[storageunit];
				break;
		}
		return ret;
	},
	fillHostForm:function(view,record,item,index,e,eOpts){
		var hostForm = Ext.getCmp("hostForm");
		hostForm.queryById("configId").setValue(record.data['configId']);
		hostForm.queryById("hostName").setValue(record.data['hostName']);
		hostForm.queryById("opsSeries").setValue(record.data['opsSeries']);
		hostForm.queryById("opsName").setValue(record.data['opsName']);
		hostForm.queryById("cups").setValue(record.data['cups']);
		hostForm.queryById("netcards").setValue(record.data['netcards']);
		hostForm.queryById("memory").setValue(record.data['memory']);
		hostForm.queryById("fmemoryunit").setValue(record.data['memoryunit']);
		hostForm.queryById("storage").setValue(record.data['storage']);
		hostForm.queryById("fstorageunit").setValue(record.data['storageunit']);
		hostForm.queryById("hostDesc").setValue(record.data['hostDesc']);
		hostForm.queryById("hostIp").setValue(record.data['hostIp']);
	},
	editHostConfig:function(){
		var record= Ext.getCmp("hostConfigGrid").getSelectionModel().getLastSelected();
		if(record){
			var hostConfigWin = Ext.getCmp("hostConfigWin");
			hostConfigWin.setTitle("查看主机详细"  );
			hostConfigWin.show();
		}
	},
	addHost:function(){
		var hostForm = Ext.getCmp("hostForm");
		var record= Ext.getCmp("hostConfigGrid").getSelectionModel().getLastSelected();
		if( hostForm.getForm().isValid()){
			var hostName = hostForm.queryById("hostName").getValue();
			record.set("hostName",hostName);
			Ext.getCmp("hostConfigWin").hide();
		}
	},
	closeHostWin:function(){
		Ext.getCmp("hostConfigWin").hide();
	},
	loadForm:function(){
		//加载资源申请表单
		 var query = new Query("ResApplyQueryHandler","_load_dataset");
		 query.setHandlerMethod("getEntity");		 
		 query.setURL('/query.asp');
		 query.addCondition("objId", this.applyId);
		 query.setCompletedFun(this.afterloadApplyForm);
		 query.setCompletedFunScope(this);
		 query.load();

		//加载审批记录
		var auditLogStore = Ext.getCmp("auditLogGrid").getStore();
  		var condition=new Condition("applyId",this.applyId);
  		auditLogStore.clearCondition();
  		auditLogStore.addCondition(condition);
  		auditLogStore.load();
	},
	afterloadApplyForm:function(success,dataset,response, opts){
		if(success){
			if( dataset && !Ext.isEmpty(dataset.record)){
				var record = dataset.record[0];
				Ext.getCmp("resApplyForm").getForm().setValues(record);
				var hostGridStore = Ext.getCmp("hostConfigGrid").getStore();
				if(	Ext.isArray(record.hostList) ){
					hostGridStore.loadData(record.hostList);
				}
			}
		}else{
			
		}
	},
	renderAuditGrid:function(value,metaData,record,rowIndex,colIndex,store,view){
		var status =['审批不通过','审批通过','执行完成','执行失败'];
		return status[value];
	},
	/**
	 * 资源使用情况查询
	 */
	queryRes:function(){
		var startDate = Ext.getCmp("startDate").getRawValue();
		var endDate = Ext.getCmp("endDate").getRawValue();
		if( !Ext.isEmpty(startDate) && !Ext.isEmpty(endDate)  ){
			var win = Ext.getCmp("resqueyWin");
			win.show();
			var url = Pls.Webpath +"/pages/rms/resgantt/ResGantt.jsp?startDate={0}&endDate={1}";
			url = url.format(startDate,endDate);
			document.getElementById("framegtt").src=url;
		}
	}
	
});